package com.heifeng.cloudshelf.mvp.show.adapter;

import android.content.Context;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.heifeng.cloudshelf.R;
import com.heifeng.cloudshelf.mvp.model.DetailImageInfo;

import java.util.List;

/**
 * Created by admin on 2019/9/12.
 */

public class ShowHomeAdapter extends RecyclerView.Adapter<ShowHomeAdapter.ViewHolder> {
    private List<List<DetailImageInfo>> data;

    private Context context;

    private LinearLayoutManager layoutManager;

    public ShowHomeAdapter(List<List<DetailImageInfo>> data, Context context) {
        this.data = data;
        this.context = context;
    }

    @Override
    public ShowHomeAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        LayoutInflater inflater = LayoutInflater.from(parent.getContext());
        View v = inflater.inflate(R.layout.layout_programme_scrollview_item, parent, false);
        return new ViewHolder(v);
    }

    @Override
    public void onBindViewHolder(ShowHomeAdapter.ViewHolder holder, int i) {
//        layoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
//        holder.recyclerView.setLayoutManager(layoutManager);
//
//        BaseQuickAdapter adapter = new ShowHomeRvAdapter(context, R.layout.layout_showhome_rv_item, data.get(i),i);
//
//        holder.recyclerView.setAdapter(adapter);

//        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
//        layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
//        layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
//        layoutParams.width = layoutParams.width - DensityUtils.dp2px(context, 5);
//        holder.layout.setLayoutParams(layoutParams);
    }

    @Override
    public int getItemCount() {
        return data.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        private RecyclerView recyclerView;
        private LinearLayout layout;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);

            recyclerView = (RecyclerView) itemView.findViewById(R.id.recyclerview);
            layout = (LinearLayout) itemView.findViewById(R.id.layout);
        }
    }
}
